<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	
	<h:head>  
  		
    </h:head> 
	
<h:body>
<ui:composition template="/WEB-INF/templates/templateMain.xhtml">
	<ui:define name="content">
	    <p:panel toggleable="true">
			<h:form>
			<h:messages></h:messages>
			
			<p:fieldset legend="Cadastro de Solicitação" toggleable="false">
				<h:panelGrid columns="2">
				
			<h:outputText value="Status da Solicitação:" />
			<h:selectOneMenu value="#{solicitacaoBean.solicitacaoSelecionada.STATUS}" id="comboStatus" >
				<f:selectItems value="#{solicitacaoBean.comboStatus}"></f:selectItems>
				<f:converter converterId="ConversorStatus"></f:converter>
			</h:selectOneMenu>
			
			<h:outputText value="Paciente:" />
			<h:selectOneMenu value="#{solicitacaoBean.solicitacaoSelecionada.PACIENTE}" id="comboPaciente" >
				<f:selectItems value="#{solicitacaoBean.comboPacientes}"></f:selectItems>
				<f:converter converterId="ConversorPaciente"></f:converter>
			</h:selectOneMenu>
			
			<h:outputText value="Médico:" />
			<h:selectOneMenu value="#{solicitacaoBean.solicitacaoSelecionada.MEDICO}" id="comboMedico" >
				<f:selectItems value="#{solicitacaoBean.comboMedicos}"></f:selectItems>
				<f:converter converterId="ConversorMedico"></f:converter>
			</h:selectOneMenu>
			
			<h:outputText value="Animal:" />
			<h:selectOneMenu value="#{solicitacaoBean.solicitacaoSelecionada.ANIMAL}" id="comboAnimal" >
				<f:selectItems value="#{solicitacaoBean.comboAnimais}"></f:selectItems>
				<f:converter converterId="ConversorAnimal"></f:converter>
			</h:selectOneMenu>
			
			<h:outputText value="Observações:" />
			<p:inputTextarea id="observações" value="#{solicitacaoBean.solicitacaoSelecionada.SOL_OBS}" autoResize="off" cols="50" rows="4"/>
			
			<h:outputText value="Solicitação Urgente:" />
			<h:selectOneMenu value="#{solicitacaoBean.flagUrgente}">
				<f:selectItems value="#{solicitacaoBean.comboUrgente}"></f:selectItems>
			</h:selectOneMenu>
			
			</h:panelGrid>
			</p:fieldset>
			
			
			
			<p:fieldset legend="Inclusão de Exames" toggleable="false">
				<h:panelGrid columns="1">
			
			<h:outputText value="Exame:" />
			<h:selectOneMenu value="#{solicitacaoBean.exameEscolhido}" onchange="submit()" id="comboExames">
				<f:selectItems value="#{solicitacaoBean.comboExames}"></f:selectItems>
				<f:converter converterId="ConversorCadastroDeExames"></f:converter>
			</h:selectOneMenu>
			
			<h:outputText value="Convênio:" />
			<h:selectOneMenu value="#{solicitacaoBean.convenioEscolhido}" id="comboConvenios">
				<f:selectItems value="#{solicitacaoBean.comboConvenios}"></f:selectItems>
				<f:converter converterId="ConversorConvenio"></f:converter>
			</h:selectOneMenu>
			
			<h:commandButton value="Adicionar Exame a solicitação" action="#{solicitacaoBean.adicionarExameASolicitacao}"/>
			<br></br>
			<p:dataTable value="#{solicitacaoBean.listaDeExames}" var="item" border="1" id="tabelaDeExames">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Exame adicionado"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.CAD_EXAME.CAD_EXAME_NOME}"></h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Convenio"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.EXAME_VALOR.CONVENIO.CONVENIO_NOME}"></h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Status do Exame"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.STATUS.STATUS_NOME}"></h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Ações"></h:outputText>
					</f:facet>
					<h:commandButton value="Entrar Resultado" action="#{resultadosBean.inicioEntradaResultado}">
						<f:setPropertyActionListener target="#{resultadosBean.exameSelecionado}" value="#{item}"></f:setPropertyActionListener>
					</h:commandButton>
					<h:commandButton value="Imprimir" action="#{relatoriosBean.inicioRelatorios}">
						<f:setPropertyActionListener target="#{relatoriosBean.exameSelecionado}" value="#{item}"></f:setPropertyActionListener>
					</h:commandButton>
				</p:column>
			</p:dataTable>
		</h:panelGrid>
		</p:fieldset>
		
		<p:fieldset legend="Controle de Pagamento" toggleable="false">
				<h:panelGrid columns="2">
			
			<h:outputText value="Desconto Percentual:" />
			<p:inputText value="#{solicitacaoBean.solicitacaoSelecionada.SOL_DESC_PERCENTUAL}" id="descontoPercentual"/>
	
			<h:outputText value="Desconto em Dinheiro:" />
			<h:inputText value="#{solicitacaoBean.solicitacaoSelecionada.SOL_DESC_DINHEIRO}" id="descontoEmDinheiro"/>
			
			<h:outputText value="Valor Total:" />
			<h:outputText value="#{solicitacaoBean.solicitacaoSelecionada.SOL_VALOR}" id="valor"/>
			
			<h:outputText value="Valor Pago:" />
			<h:inputText value="#{solicitacaoBean.solicitacaoSelecionada.SOL_VALOR_PAGO}" id="valorPago"/>
		
			<p:commandButton value="Gravar Solicitação" action="#{solicitacaoBean.botaoGravar}" ajax="false"/>
			<p:commandButton value="Voltar Para Listagem" action="#{solicitacaoBean.retornarListagemSolicitacoes}" ajax="false"/>
			
			<p:commandButton value="Limpar Tela" action="#{solicitacaoBean.limparTela}" ajax="false"/>
			
			</h:panelGrid>
		</p:fieldset>
		
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
</h:body>
</html>